home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.asm.x86,comp.lang.c,comp.lang.c++
- Path: indra.com!sullivan
- From: sullivan@indra.com (Steve Sullivan)
- Subject: Catch Fixed Point Overflow in C or C++
- Message-ID: <DnJpxH.CDw.0.net@indra.com>
- Organization: Indra's Net - Public Internet Access
- Date: Thu, 29 Feb 1996 16:32:05 GMT
-
- Is it possible to have a Pentium assembler routine set up so
- that fixed-point overflow in C or C++ is caught? For example,
- would either of the following approaches work?
-
- Approach 1:
- /* here carryflag() is an asm routine to return the carry flag */
- int sum, i, j;
- long lprod, li, lj;
- sum = i + j;
- if ( carryflag()) printf("sum overflow occured\n");
- lprod = li * lj;
- if ( carryflag()) printf("prod overflow occured\n");
-
- Approach 2:
- int sum, i, j;
- long lprod, li, lj;
- setOverCheck(); /* this is an asm routine that enables
- "interrupt on overflow" */
- try {
- sum = i + j; /* get exception if overflow occurs */
- lprod = li * lj; /* get exception if overflow occurs */
- }
- catch (const char * msg) { printf("overflow occured in %s\n", msg); }
-
- Approach 2 would be much preferred, if possible, since it doesn't
- require checking after each operation as in approach 1.
-
- Where could I find such asm code, or references on how to write it?
- I don't know x86 asm, but if need be I'll learn it (sigh!).
- Also, would similar approaches work to detect floating point exceptions?
-
- Many thanks for any suggestions --
-
- Steve Sullivan
-
-
-